package org.hgvc.webapp.ets.jsf.beans.member;

import org.hgvc.webapp.ets.bo.Member;
import org.hgvc.webapp.ets.constant.CommonConstant;
import org.hgvc.webapp.ets.spring.service.MemberService;
import org.jocsb.base.AbstractBean;
import org.jocsb.base.exception.BaseException;
import org.jocsb.base.util.FacesUtils;


public class MemberPortalBean extends AbstractBean {

	public static final String BEAN_NAME="memberPortalBean";
	public static final String NAV_MEMBER_PORTAL="memberPortal";
	private Member member;
	private MemberService service;
	
	public Member getMember() {
		return member;
	}
	public void setMember(Member member) {
		this.member = member;
	}
	public void setService(MemberService service) {
		this.service = service;
	}
	public void setInit(String test){}
	/******************************************************/

	public String getInit(){
		try{
			if(member==null)
				member = service.getMemberByUserId(getThisUser().getUserId());
		}catch(BaseException be){
			be.printStackTrace();
			initErrorBean(be);
		}
		return null;
	}
	
	public String navViewProfile(){
		if(member.getMemberType().equalsIgnoreCase(CommonConstant.MEMBER_TYPE_IND)){
			MemberIndProfileBean bean = (MemberIndProfileBean)FacesUtils.getManagedBean(MemberIndProfileBean.BEAN_NAME);
			return bean.navViewAction(member);
		}else{
			MemberCompProfileBean bean = (MemberCompProfileBean)FacesUtils.getManagedBean(MemberCompProfileBean.BEAN_NAME);
			return bean.navViewAction(member);
		}
	}
	
}
